C lets you create data structures. A structure is a collection of C data types which you want to treat as a single entity. In C a lump of data would be called a structure and each part of it would be called a member. To help us with our bank database we could create a structure which could hold all the information about a customer. On the right you can see how this is declared.
The first declaration sets up a variable called OnlyOne, which can hold the information for a single customer. The second declaration sets up an entire array of customers, called EveryOne which can hold all the customers.
We refer to individual members of a structure by putting their name after the structured variable we are using with a . separating them, for example :
OnlyOne.balance = 0 ;
- would refer to the integer member account in the structured variable OnlyOne. In the statement above I am setting the balance of the OnlyOne account to 0.
You can do this with elements of an array of structures too, so that :
EveryOne [25].account
- would be the account number of customer element 25 from the start of the array.
/* Create a customer structure */ struct customer { char name [30] ; char address [60] ; int account ; int balance ; int overdraft ; } ; /* declare a single customer */ struct customer OnlyOne ; /* declare an array */ struct customer EveryOne [50] ;